
import random
from re import search


def BubbleSort():
    ArrayLength = 10
    for x in range(0,1): #  M: -1
        for y in range(0,ArrayLength-1):
            for z in range(0,ArrayLength-y-1):
                if ArrayData[x][z] > ArrayData[x][z+1]:
                    TempValue = ArrayData[x][z]
                    ArrayData[x][z] = ArrayData[x][z+1]
                    ArrayData[x][z+1] = TempValue
        if x == 2:         # x==2:index out of range
            break

# 输出不对哦 M: -1
def PrintArray():
    for x in range(0,9): #M: -1
        print(f'{ArrayData[0][x]} {ArrayData[1][x]}')  # 啊？ -1

def BinarySearch(SearchArray,Lower,Upper,SearchValue):
    if Upper >= Lower:
        Mid = (Lower+(Upper-1))//2 # -1
        if SearchArray[0][Mid] == SearchValue:
            return Mid
        else:
            if SearchArray[0][Mid] > SearchValue:
                return BinarySearch(SearchArray,Lower-1,Mid-1,SearchValue)  # -1
            else:
                return BinarySearch(SearchArray,Mid+1,Upper+1,SearchValue) # -1
    return -1



if __name__ == '__main__':
    ArrayData = [[random.randint(1,100) for i in range(10)],[0 for i in range(10)]]

    PrintArray()
    print('----------')
    BubbleSort()
    PrintArray()

    print(BinarySearch(ArrayData,0,9,10))
    print(BinarySearch(ArrayData,0,9,-1))